﻿using Engine;
using Game;
using Mekiasm.Common;
namespace Mekiasm
{
    public class LogisticalSorter : ComplexModelItem
    {
        public static int Index;

        public LogisticalSorter() : base(new ModelItem[] {
            new ModelItem("ring5", "logistical_sorter"), new ModelItem("portBack", "logistical_sorter"), new ModelItem("led3", "logistical_sorter"),
            new ModelItem("panel1", "logistical_sorter"), new ModelItem("pistonBase1", "logistical_sorter"), new ModelItem("ring2", "logistical_sorter"),
            new ModelItem("led4", "logistical_sorter"), new ModelItem("ring4", "logistical_sorter"), new ModelItem("pistonBar2", "logistical_sorter"),
            new ModelItem("pistonBrace1", "logistical_sorter"), new ModelItem("pipe", "logistical_sorter"), new ModelItem("portFront", "logistical_sorter"),
            new ModelItem("pistonBase2", "logistical_sorter"), new ModelItem("led2", "logistical_sorter"), new ModelItem("ring3", "logistical_sorter"),
            new ModelItem("led1", "logistical_sorter"), new ModelItem("pistonBar1", "logistical_sorter"), new ModelItem("connectorBack", "logistical_sorter"),
            new ModelItem("ring7", "logistical_sorter"), new ModelItem("pistonConnector2", "logistical_sorter"), new ModelItem("ring1", "logistical_sorter"),
            new ModelItem("pistonBrace2", "logistical_sorter"), new ModelItem("pistonConnector1", "logistical_sorter"), new ModelItem("panel2", "logistical_sorter"),
            new ModelItem("ring6", "logistical_sorter"), new ModelItem("portBackLarge", "logistical_sorter")
        }, "物流整理机", "物流整理机")
        {
            

        }

        public override MekBlock.DeviceType GetDeviceType()
        {
            return MekBlock.DeviceType.Item;
        }

        public override bool OnUse(Ray3 aim, ComponentMiner componentMiner, TerrainRaycastResult? raycast)
        {
            return false;
        }
        public override void OnBlockAdded(SubsystemBlockBehavior blockBehavior, int value, int oldValue, int x, int y, int z)
        {
            ILibrary.AddBaseEnergyEntity(DisplayName, x, y, z, null, ILibrary.GetRotetedConfig(value, new MachineFaceConfig[] {
            new MachineFaceConfig(MekBlock.MachineMode.IN,MekBlock.DeviceType.Item),
            new MachineFaceConfig(),
            new MachineFaceConfig(MekBlock.MachineMode.OUT,MekBlock.DeviceType.Item),
            new MachineFaceConfig(),
            new MachineFaceConfig(),
            new MachineFaceConfig()
            }));
            ItemSystem.Add(new ItemElement.WLZLJElement(x, y, z));
        }
        public override void OnBlockGenerated(int value, int x, int y, int z, bool isLoaded)
        {
            ItemSystem.Add(new ItemElement.WLZLJElement(x, y, z));
        }
        public override void OnBlockRemoved(SubsystemBlockBehavior blockBehavior, int value, int newValue, int x, int y, int z)
        {
            ILibrary.RemoveBlockEntity(x, y, z);
            ItemSystem.Remove(x, y, z);
        }


    }
}
